# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=leena
pkgver=2.5119f56
pkgrel=1
pkgdesc='Symbolic execution engine for JavaScript'
arch=('any')
groups=('blackarch' 'blackarch-binary' 'blackarch-code-audit')
url='https://github.com/mmicu/leena'
license=('GPL3')
depends=('nodejs')
makedepends=('git' 'npm')
source=("git+https://github.com/mmicu/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)

}

prepare() {
  cd $pkgname

  npm install
  node_modules/grunt-cli/bin/grunt --force
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec node bin/$pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

